<template>
  <div class="container">
    <div class="x-radio-item">
      <img :src="this.$parent.getValue() === this.label ? src[1] : src[0]" @click="handleClick" />
      <slot></slot>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'XRadio',
    props: ['label'],
    data() {
      return {
        src: ['/images/radio.svg', '/images/radio-checked.svg'],
      }
    },
    methods: {
      handleClick() {
        this.$parent.changeValue(this.label)
      },
    },
  }
</script>

<style lang="scss" scoped>
  .container {
    display: inline-block;
  }
  .x-radio-item {
    display: flex;
    align-items: center;
  }
</style>
